<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" xmlns:c="livcos.org/ns/cosmos" xmlns:job="livcos.org/ns/process/job" version="2.0" exclude-result-prefixes="job c">
  
  <xsl:import href="../../style/base.xsl"/>
  
  <xsl:variable name="access" select="/*/c:request/access"/>
	<xsl:variable name="toAccessRootPath"
	select="substring(string-join(for $s in tokenize($access/@uri, '/') return '..', '/'), 7)"/>
	<xsl:variable name="toLivCosPath" select="concat($toAccessRootPath, '/livcos.org')"/>

	<xsl:param name="objUri" select="$access/@obj | $access/@objId"/>
  
  <xsl:output method="html" encoding="UTF-8" doctype-public="-//W3C//DTD HTML 4.01//EN" doctype-system="http://www.w3.org/TR/html4/strict.dtd"/>
  
  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="*" priority="1">
    <xsl:text>
</xsl:text>
    <xsl:for-each select="ancestor::*">
      <xsl:text>  </xsl:text>
    </xsl:for-each>
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
      <xsl:if test="*">
      <xsl:text>
</xsl:text>
      <xsl:for-each select="ancestor::*">
        <xsl:text>  </xsl:text>
      </xsl:for-each></xsl:if>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="/">
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>Object Missing</title>
      	<link href="{$toLivCosPath}/web/css/global.css" rel="stylesheet" type="text/css"/>
        <link href="{$toLivCosPath}/web/css/web.css" rel="stylesheet" type="text/css"/>
        <link href="{$toLivCosPath}/web/css/gui.css" rel="stylesheet" type="text/css"/>
        <link href="{$toLivCosPath}/web/css/status.css" rel="stylesheet" type="text/css"/>
        <link href="{$toLivCosPath}/web/css/webXml.css" rel="stylesheet" type="text/css"/>
      	<script type="text/javascript" src="{$toLivCosPath}/web/script/util.js"><!-- --></script>
      	<script type="text/javascript" src="{$toLivCosPath}/web/script/E.js"><!-- --></script>
        <script type="text/javascript" src="{$toLivCosPath}/web/script/init.js"><!-- --></script>
        <script type="text/javascript" src="{$toLivCosPath}/web/script/doc.js"><!-- --></script>
        <script type="text/javascript" src="{$toLivCosPath}/web/script/gui.js"><!-- --></script>
        <script type="text/javascript" src="{$toLivCosPath}/web/script/creator.js"><!-- --></script>
      </head>
      <body>
      	<h1>Object missing for <a href="{$toAccessRootPath}{*/c:request/access/@uri}">
            <xsl:value-of select="*/c:request/access/@uri"/>
          </a>!</h1>
        <div style="background-color: LightBlue; padding: 6px 4px; margin: 10px 0px;">
          <p><a href="javascript:Dom('job_details').toggle();">Job Details</a></p>
          <textarea id="job_details" rows="20" style="width:100%; display: none;" nowrap="1">
            <xsl:apply-templates select="*"/>
          </textarea>
        </div>
        <div style="background-color: LightBlue; padding: 6px 4px; margin: 10px 0px;">
          <p>You can create a new object.</p>
          <form>
            <table style="width: 98%">
              <tbody>
                <tr>
                  <td style="width: 10%; text-align: right; margin-right: 4px;">Object:</td>
                  <td>
                    <div style="position: relative;">
                      <input name="objId" id="objId" type="text" value="{$objUri}" style="width:80%"/>
                    </div>
                  </td>
                </tr>
                <tr>
                  <td style="width: 10%; text-align: right; margin-right: 4px;">Template:</td>
                  <td>
                    <div style="position: relative;">
                      <input name="tmplId" id="tmplId" type="text" value="/livcos.org/type/template/livcos.org/ns/doc/document" style="width:80%"/>
                    	[<a href="javascript:setTmpl('/livcos.org/type/template/livcos.org/ns/doc/document')">Doc</a>]
                    	[<a href="javascript:setTmpl('/livcos.org/type/template/livcos.org/ns/map/map')">Map</a>]
                    </div>
                  </td>
                </tr>
                <tr>
                  <td colspan="2" style="text-align: right; margin-right: 20px;">
                    <a href="javascript:createObject()">Create</a>
                  </td>
                </tr>
              </tbody>
            </table>
          </form>
          <p id="message"> </p>
          <div id="response" style="display: none; background-color: white;"/>
        </div>
      </body>
    </html>
  </xsl:template>
  
</xsl:stylesheet>